*exportrif.ado 	JEP		01/25/15
* Program to export results of RIF regressions


*************************** Change log ********************************** 

/*
	04/11/15	Add exception for regressions without CGM
	07/10/15	Add .txt file to register so they don't get archived and hang around
				Add option to register the ster file, will only register the actual ster files for the third year paper tables
*/	
version 13.1

cap program drop exportrif
program exportrif
	syntax , name(string) p(integer) r(string) [register rster]
	cap assert e(bh_wild)=="."
	if _rc {
		outreg2 using "`name'", bdec(4) se ctitle(p`p') `r' excel keep(treat*) adds(Wild BS P-val , e(tp), LB-Wild, e(bl_wild), UB-Wild, e(bh_wild))
	}
	else {
		outreg2 using "`name'", bdec(4) se ctitle(p`p') `r' excel keep(treat*)  adds(P-val , e(tp))
	}
	est save "`name'_p`p'", replace
	if "`register'"=="register" {
		project, creates(`name'.xml) preserve
		project, creates(`name'.txt) preserve
	}
	if "`rster'"=="rster" {
		project, creates(`name'_p`p'.ster) preserve
	}
end
